﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace JY.Wpf.Controls.Converters
{
    /// <summary>
    /// 状态转画刷转换器
    /// </summary>
    public class StatusToBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.LightGray);

            if (value != null)
            {
                bool.TryParse(value.ToString(), out bool channelStatus);
                solidColorBrush = channelStatus ? new SolidColorBrush(Colors.GreenYellow) : new SolidColorBrush(Colors.LightGray);
            }

            return solidColorBrush;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
